package com.song;

import com.song.config.SpringConfig;
import com.song.vo.Cat;
import com.song.vo.Student;
import com.song.vo.Tiger;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @ClassName : Mytest
 * @Author : 司猫子
 * @Date: 2021/2/28 19:15
 */

public class Mytest {

    @Test
    public void test01(){
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
        Student student = (Student) ctx.getBean("myStudent");
        System.out.println(student);
    }

    @Test
    public void test02(){
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class);
        Student student = (Student) ctx.getBean("createStudent");
        System.out.println(student);

        System.out.println("========");

        Student student1 = (Student) ctx.getBean("lisiStudent");
        System.out.println(student1);
    }
    @Test
    public void  test03(){
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class);
        Student student = (Student) ctx.getBean("myStudent");
        Cat cat = (Cat) ctx.getBean("myCat");
        System.out.println(student);
        System.out.println(cat);

    }

    @Test
    public void test04(){
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class);
        Tiger tiger = (Tiger) ctx.getBean("myTiger");
        System.out.println(tiger);

    }



}
